From f08a9d32886d19ef582546c2bcc136faf816e0e9 Mon Sep 17 00:00:00 2001 From: Martin Sehnoutka Date: Thu, 29 Jun 2017 09:53:57 +0200 Subject: [PATCH] Add documentation for multi-file binary convention --- src/doc/manifest.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/doc/manifest.md b/src/doc/manifest.md index 4671e3694..67d9afa86 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -457,8 +457,11 @@ Most of the time workspaces will not need to be dealt with as `cargo new` and If your project is an executable, name the main source file `src/main.rs`. If it is a library, name the main source file `src/lib.rs`. -Cargo will also treat any files located in `src/bin/*.rs` as executables. Do -note, however, once you add a `[[bin]]` section ([see +Cargo will also treat any files located in `src/bin/*.rs` as executables. If your +executable consist of more than just one source file, you might also use a directory +inside `src/bin` containing a `main.rs` file which will be treated as an executable +with a name of the parent directory. +Do note, however, once you add a `[[bin]]` section ([see below](#configuring-a-target)), Cargo will no longer automatically build files located in `src/bin/*.rs`. Instead you must create a `[[bin]]` section for each file you want to build. @@ -473,6 +476,8 @@ integration tests, and benchmarks respectively. main.rs # the main entry point for projects producing executables ▾ bin/ # (optional) directory containing additional executables *.rs + ▾ */ # (optional) directories containing multi-file executables + main.rs ▾ examples/ # (optional) examples *.rs ▾ tests/ # (optional) integration tests -- 2.30.2